package com.dongdongsongcan.app.control;

import com.dongdongsongcan.app.control.bean.CategoryData;
import com.dongdongsongcan.app.control.bean.LabelData;
import com.dongdongsongcan.app.control.bean.MenuGroupData;
import com.dongdongsongcan.app.control.bean.MenuListData;
import com.dongdongsongcan.app.control.bean.RecommendAdData;
import com.dongdongsongcan.app.control.bean.ShopData;
import com.dongdongsongcan.app.model.api.WebServiceApi;
import com.su.dolphin.control.bean.BaseBean;
import com.su.dolphin.control.task.CtrlTask;
import com.su.dolphin.control.task.CtrlTask.IControlResponse;
import com.su.dolphin.control.task.CtrlTask.IControlWork;

/**
 * 获取店铺数据的控制器
 *
 * @author Alex
 */
public class ShopControl {

    private static ShopControl sShopsControl;

    private ShopControl() {
    }

    public static ShopControl i() {
        if (sShopsControl == null) {
            sShopsControl = new ShopControl();
        }
        return sShopsControl;
    }

    public void getCategoryDatas(IControlResponse<CategoryData> response) {
        CtrlTask.submitTask(new IControlWork() {

            @Override
            public BaseBean doWork() {
                return WebServiceApi.getCategoryData();

            }
        }, response);

    }

    public void getRecommendAds(IControlResponse<RecommendAdData> response) {
        CtrlTask.submitTask(new IControlWork() {

            @Override
            public BaseBean doWork() {
                return WebServiceApi.getRecommendAdData();
            }
        }, response);

    }

    public void getLabels(IControlResponse<LabelData> response) {
        CtrlTask.submitTask(new IControlWork() {

            @Override
            public BaseBean doWork() {
                return WebServiceApi.getLabelData();
            }
        }, response);
    }

    public void getMenuGroupData(IControlResponse<MenuGroupData> response,
                                 final int shopid) {
        CtrlTask.submitTask(new IControlWork() {

            @Override
            public BaseBean doWork() {
                return WebServiceApi.getMenuGroupData(shopid);
            }
        }, response);
    }

    public void getMenuListData(IControlResponse<MenuListData> response,
                                final int shopid, final int groupid, final int per_page,
                                final int limits) {
        CtrlTask.submitTask(new IControlWork() {

            @Override
            public BaseBean doWork() {
                return WebServiceApi.getMenuListData(shopid, groupid, per_page,
                        limits);
            }
        }, response);
    }

    public void getShops(final String shop_label, final String shop_type, final String orderby, final int offset, final int pagesize, final double site_x, final double site_y,
                         IControlResponse<ShopData> response) {
        CtrlTask.submitTask(new IControlWork() {

            @Override
            public BaseBean doWork() {
                return WebServiceApi.getShops(shop_label, shop_type, orderby, offset, pagesize, site_x, site_y);
            }
        }, response);

    }


}
